<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>CMS</title>
<link href="__CSS__/common.css" rel="stylesheet"/>
<link href="__CSS__/right.css" rel="stylesheet"/>
<link rel="stylesheet" href="__INC__/form/css/zebra_form.css" type="text/css">
<script type="text/javascript" language="javascript" src="__JS__/jquery-1.7.2.min.js"></script>
<script type="text/javascript" language="javascript" src="__JS__/FusionCharts.js"></script>
<script type="text/javascript" language="javascript" src="__JS__/common.js"></script>
<script type="text/javascript" language="javascript">
    $(document).ready(function () {
        $(".table_list tr").mouseover(function () {
            $(this).addClass("one");
        })
        $(".table_list tr").mouseout(function () {
            $(this).removeClass("one");
        })
    });
</script>
<style type="text/css">
    .one {
        background: #fcfcfc;
    }
</style>
<style type="text/css">
    #panel {
        width: 100%;
    }

    .lm_content {
        padding-top: 10px;
    }

    .infos_left {
        float: left;
        display: inline;
        /*height:110px;*/
    }

    .infos_right {
        width: 150px;
        float: left;
        display: inline;

    }

    .Zebra_Form .row input {
        margin: 0px;
    }

    .Zebra_Form .row input.text {
    }

    .Zebra_Form .row input.button {
        _width: 80px;
        _padding: 2px 10px 3px;
        _height: 22px;
    }

    .Zebra_Form .row input.button2 {
        _width: 40px;
        _padding: 0px 0px 0px;
        _overflow: hidden;
    }

    .Zebra_Form td {
        padding: 0 0 0 10px;
        _padding: 0 0 0 5px;
    }
</style>
</head>
<body>
<!--右侧区域 begin-->
<div class="right">
    <!--当前位置 begin-->
    <include file='common:crumbs'/>
    <!--当前位置 end-->
    <!--主体区域 begin-->
    <div class="container">
        <div class="alert_div">
            <h4 class="alert_info"><span class="welcome">{$welcome}</span>您现在的位置是：{$current} </h4>
            <h4 class="alert_what" style="display:none;"></h4>
        </div>
        <!--样式一 begin-->
        <div class="stats">
            <div class="lm_title">
                <div class="lm_title_l">
                    <em>操作面板</em>
                </div>
            </div>
            <div class="lm_content">
                <div id="panel">
                    <div class="infos_left">
                        <table class="Zebra_Form">
                            <?php
                                $write_check = Permission::check($tid,"w");
                                $check_check = Permission::check($tid,"c");
                                if( $write_check || $check_check ){
                            ?>
                            <tr class="row">
                                <?php
                                    if($write_check){
                                ?>
                                <td><label>操作</label></td>
                                <if condition="$tid neq 48">
                                <td><input type="button" class="button" onclick="addcontent()" value="添加内容"/></td>
                                <td><input type="button" class="button" onclick="openpanel('del')" value="<?php if($type == 1) echo '删除'; else echo '删除'; ?> "/></td>
                                <td><input type="button" class="button" onclick="openpanel('move')" value="内容移动"/></td>
                                </if>
                                <td><input type="button" class="button" onclick="$('#sortrankform').submit();" value="保存权重"/></td>
                                <?php if($type == 1){  ?>
                                <td><input type="button" class="button" onclick="openpanel('addflag')" value="添加属性"/></td>
                                <td><input type="button" class="button" onclick="openpanel('delflag')" value="移除属性"/></td>
                                <?php }?>
                                <?php }?>
                                <?php
                                    if($check_check){
                                ?>
                                <!--td><input type="button" class="button" onclick="openpanel('push')" value="推送" /></td-->
                                <td><input type="button" class="button" onclick="openpanel('check')" value="审核"/></td>
                                <?php }?>
                            </tr>
                            <?php }?>
                            <form action='__GROUP__/content/show' method="post">
                                <tr class="row">
                                    <input type="hidden" name="action" value="filter"/>
                                    <input type="hidden" name="cid" value="{$cid}"/>
                                    <input type="hidden" name="tid" value="{$tid}"/>
                                    <input type="hidden" name="type" value="{$type}"/>
                                    <td><label>搜索:</label></td>
                                    <td><select name="searchby">
                                        {$searchby_html}
                                    </select></td>
                                    <td colspan="3"><input type="text" name="searchkey" class="text" value="{$searchkey}"/></td>
                                    <td><input type="submit" class="button" value="搜索"/></td>
                                </tr>
                                <tr class="row">
                                    <td><label>排序:</label></td>
                                    <td><select name="orderby">
                                        {$orderby_html}
                                    </select></td>
                                    <td><input type="submit" class="button" value="排序"/></td>
                                </tr>
                            </form>
                        </table>
                    </div>
                    <div class="infos_right">{$chart_html}</div>
                    <div class="clear"></div>
                </div>
            </div>
            <div class="lm_bottom">
                <div class="lm_bottom_l">
                    <em></em>
                </div>
            </div>
        </div>
        <!--样式一 end-->
        <!--样式二 begin-->
        <div class="stats">
            <div class="lm_title">
                <div class="lm_title_l">
                    <em>{$current}</em>
                </div>
            </div>
            <div class="lm_table">
                <eq name="type" value="2">
                    <include file="list2" />
                <else/>
                    <include file="list1" />
                </eq>
            </div>
            <div class="lm_table_bottom">
                <div class="lm_table_bottom_l">
                    <em>
                        <div class="select_btn"><input type="button" class="select_btn1" onclick="selAll()" value=""/>&nbsp;&nbsp;<input type="button" onclick="selRev()" class="select_btn2" value=""/></div>
                        <div class="page">{$page}</div>
                        <div class="clear"></div>
                    </em>
                </div>
            </div>
        </div>
        <!--样式二 end-->
    </div>
    <!--主体区域 end-->
</div>
<!--右侧区域  end-->

<!--弹出层二begin-->
<div class="popupPanel">
    <div class="stats">
        <div class="lm_title">
            <div class="lm_title_l"><em id="panelTitle">做什么？</em></div>
        </div>
        <div class="lm_content">
            <table class="Zebra_Form" style="width:100%;">
                <tr class="row">
                    <td width="60"><label>已选ID：</label></td>
                    <input type="hidden" id="controlitems" value=""/>
                    <input type="hidden" id="panelaction" value=""/>
                    <td colspan="2" id="checked_items"><label style="color:#FF00AE;"></label></td>
                </tr>
                <tr class="row movePanel" style="display:none;">
                    <td width="80"><label>目的栏目：</label></td>
                    <td colspan="2">
                        <select name="totid" id="movetoselect">
                        </select>
                    </td>
                </tr>
                <tr class="row addflagPanel" style="display:none;">
                    <td width="80"><label>勾选属性：</label></td>
                    <td colspan="2">
                        {$flagSelect_html}
                    </td>
                </tr>
                <tr class="row sitePanel" style="display:none;">
                    <td width="80"><label>目的站点：</label></td>
                    <td colspan="2" id="checked_site">
                        <select name="tositeid" id="tositeselect" onchange="changeSiteArctype(this.value)">
                            <volist name="sitesArr" id="vo">
                                <option value="{$vo['id']}">{$vo['name']}</option>
                            </volist>
                        </select>
                    </td>
                </tr>
                <tr class="row arctypePanel" style="display:none;">
                    <td width="80"><label>目的栏目：</label></td>
                    <td colspan="2" id="checked_arctype">
                        <input type="hidden" id="real_cid"/>
                        <input type="hidden" id="real_tid"/>
                        <select name="totid" id="tositearctype">
                        </select>
                    </td>
                </tr>
                <tr class="row">
                    <td></td>
                    <td><input type="button" onclick="panelDo()" class="button" value="确定"/></td>
                    <td><input type="button" class="button" onclick="panelClose()" value="取消"/></td>
                </tr>
            </table>
        </div>
        <div class="lm_bottom">
            <div class="lm_bottom_l"><em></em></div>
        </div>
    </div>
</div>
<!--弹出层二end-->
</body>
<script>
/**
 *添加新内容
 */
function addcontent() {
    location = "__GROUP__/content/add?tid={$tid}&cid={$cid}";
}

function changeSiteArctype(sid) {
    var tid = $("#real_tid").val();
    var cid = $("#real_cid").val();
    $("#tositearctype").html('');
    $.post("__GROUP__/ajax/getArctypeForPush", {tid: tid, sid: sid, cid: cid}, function (data) {
        if (data != '') {
            $("#tositearctype").html(data);
            $(".arctypePanel").show();
        } else {
            jl_notify(2, "指定站点没有可以推送的栏目！");
            return;
        }
    });
}

//开启panel窗口
function openpanel(act, item) {
    //初始化关闭所有附加panel
    $(".movePanel").hide();
    $(".addflagPanel").hide();
    $(".sitePanel").hide();
    $(".arctypePanel").hide();
    if (item === undefined || typeof(item) == 'undefined') {
        item = getSelects();
    }
    if (item == '') {
        jl_notify(3, "你没有选中任何项！");
        return;
    }
    $("#controlitems").val(item);
    $('#checked_items label').text(item);
    if (act == 'del') {
        $("#panelTitle").text("你确定要删除这些内容？");
        $("#panelaction").val("del");
        var obj = $('.popupPanel');
        jl_fadeIn(obj);
    } else if (act == 'pushdel') {
        $("#panelTitle").text("你确定要删除这些推送来的内容？");
        $("#panelaction").val("pushdel");
        var obj = $('.popupPanel');
        jl_fadeIn(obj);
    } else if (act == 'move') {
        var tid = '{$tid}';
        var cid = '{$cid}';
        var type = '{$type}';
        var items = getSelects();
        $.post("__GROUP__/ajax/contentMoveSelect", {items: items, cid: cid, type: type, tid: tid}, function (data) {
            if (data == -1) {
                jl_notify(3, "异步获取可选父栏目失败!");
                return false;
            } else if (data == -2) {
                jl_notify(3, "批量移动的内容必须属于同一内容模型！");
                return false;
            } else {
                $("#movetoselect").html(data);
                var obj = $('.popupPanel');
                jl_fadeIn(obj);
            }
        })
        $(".movePanel").show();
        $("#panelTitle").text("你确定要移动这些内容？");
        $("#panelaction").val("move");
    } else if (act == 'addflag') {
        $(".addflagPanel").show();
        $("#panelTitle").text("你确定要给这些内容添加属性？");
        $("#panelaction").val("addflag");
        var obj = $('.popupPanel');
        jl_fadeIn(obj);
    } else if (act == 'delflag') {
        $(".addflagPanel").show();
        $("#panelTitle").text("你确定要给这些内容移除属性？");
        $("#panelaction").val("delflag");
        var obj = $('.popupPanel');
        jl_fadeIn(obj);
    } else if (act == 'check') {
        $("#panelTitle").text("你确定要审核这些内容？");
        $("#panelaction").val("check");
        var obj = $('.popupPanel');
        jl_fadeIn(obj);
    } else if (act == 'push') {
        var defaultsid = '{$sid}';
        $("#tositeselect option[value=" + defaultsid + "]").attr("selected", "selected");

        var tid = '{$tid}';
        var cid = '{$cid}';
        var type = '{$type}';
        var items = getSelects();
        $.post("__GROUP__/ajax/checkChannelUnity", {items: items, cid: cid, type: type, tid: tid}, function (data) {
            if (data != '') {
                if (data['code'] == -1) {
                    jl_notify(2, data['msg']);
                    return;
                } else if (data['code'] == 1) {
                    $("#real_cid").val(data['data']['cid']);
                    $("#real_tid").val(data['data']['tid']);
                    $(".sitePanel").show();
                    $("#panelTitle").text("请选择推送到到的位置！");
                    $("#panelaction").val("push");
                    var obj = $('.popupPanel');
                    jl_fadeIn(obj);
                    return;
                }
            }
        }, 'json');
    } else {
        jl_notify(3, "不知道你到底要干什么！");
        return;
    }
}

//关闭panel窗口
function panelClose() {
    var obj = $('.popupPanel');
    jl_fadeOut(obj);
}

//panel执行操作
function panelDo() {
    var act = $("#panelaction").val();
    if (act == '') {
        jl_notify(3, "不知道你到底要干什么！");
        return;
    }

    if (act == 'del') {
        var cid = '{$cid}';
        var type = '{$type}';
        jl_fadeOut($('.popupPanel'));
        var items = $("#controlitems").val();
        $.post("__GROUP__/ajax/delContent", {items: items, cid: cid, type: type}, function (data) {
            if (data == -1) {
                jl_notify(2, "删除这些内容失败！");
            } else if (data == 1) {
                //jl_notify(1,"嘻嘻，删除栏目成功！");
                location.href = location.href;
            } else {
                jl_notify(2, "种种原因导致删除这些内容失败！");
            }
        });
    } else if (act == 'pushdel') {
        var cid = '{$cid}';
        var sid = '{$sid}';
        jl_fadeOut($('.popupPanel'));
        var items = $("#controlitems").val();
        $.post("__GROUP__/ajax/delpushdata", {items: items, cid: cid, sid: sid}, function (data) {
            if (data == -1) {
                jl_notify(2, "删除推送内容失败！");
            } else if (data == 1) {
                location.href = location.href;
            } else {
                jl_notify(2, "种种原因导致删除推送内容失败！");
            }
        });
    } else if (act == 'move') {
        jl_fadeOut($('.popupPanel'));
        var tid = $("#movetoselect").val();
        var items = $("#controlitems").val();
        var cid = '{$cid}';
        var type = '{$type}';
        $.post("__GROUP__/ajax/moveContent", {items: items, tid: tid, cid: cid, type: type}, function (data) {
            if (data == -1) {
                jl_notify(2, "移动内容失败！");
            } else if (data == 1) {
                //jl_notify(1,"嘻嘻，删除栏目成功！");
                location.href = location.href;
            } else {
                jl_notify(2, "种种原因导致移动内容失败！");
            }
        });
    } else if (act == 'addflag') {
        jl_fadeOut($('.popupPanel'));
        var items = $("#controlitems").val();
        var flags = getSelects("flag[]");
        $.post("__GROUP__/ajax/addflag", {items: items, flags: flags}, function (data) {
            if (data == -1) {
                jl_notify(2, "添加属性失败！");
            } else if (data == 1) {
                location.href = location.href;
            } else {
                jl_notify(2, "种种原因导致添加属性失败！");
            }
        });
    } else if (act == 'delflag') {
        jl_fadeOut($('.popupPanel'));
        var items = $("#controlitems").val();
        var flags = getSelects("flag[]");
        $.post("__GROUP__/ajax/delflag", {items: items, flags: flags}, function (data) {
            if (data == -1) {
                jl_notify(2, "移除属性失败！");
            } else if (data == 1) {
                location.href = location.href;
            } else {
                jl_notify(2, "种种原因导致移除属性失败！");
            }
        });
    } else if (act == 'check') {
        jl_fadeOut($('.popupPanel'));
        var items = $("#controlitems").val();
        var cid = '{$cid}';
        var type = '{$type}';
        $.post("__GROUP__/ajax/commonCheck", {items: items, cid: cid, type: type}, function (data) {
            if (data == -1) {
                jl_notify(2, "审核内容失败！");
            } else if (data == 1) {
                location.href = location.href;
            } else {
                jl_notify(2, "审核内容失败！");
            }
        });
    } else if (act == 'push') {
        var items = $("#controlitems").val();
        var ttid = $("#tositearctype").val();
        var sid = $("#tositeselect").val();
        var tid = $("#real_tid").val();
        var cid = $("#real_cid").val();
        var type = '{$type}';
        var fsid = '{$sid}';
        if (sid == '' || sid == null) {
            jl_notify(3, "请先指定推送站点！");
            return;
        }
        if (sid == fsid) {
            jl_notify(3, "不能给本站推送内容！");
            return;
        }
        if (ttid == '' || ttid == null) {
            jl_notify(3, "请先指定推送栏目！");
            return;
        }
        $.post("__GROUP__/ajax/pushdata", {items: items, tid: tid, ttid: ttid, sid: sid, cid: cid, type: type}, function (data) {
            if (data != '') {
                if (data['code'] == -1) {
                    jl_notify(2, data['msg']);
                    return;
                } else if (data['code'] == 1) {
                    jl_notify(1, data['msg']);
                    return;
                }
            }
        }, 'json');
    } else {
        jl_notify(3, "不知道你到底要干什么！");
        return;
    }
}
</script>
</html>
